import {App} from "vue";
import * as elIcons from "@element-plus/icons-vue";
import {registerStore} from "@/store";

export default {
    install(app: App<Element>) {
        //初始化Store
        registerStore();

        //统一注册el-icon图标
        Object.entries(elIcons).forEach(([icon, component]) => {
            app.component(`ElIcon${icon}`, component)
        });

        // 动态加载组件
        // const components = import.meta.glob(['/src/components/*/index.vue'], { import: 'default',eager: true });
        // Object.entries(components).forEach(([path, component]) => {
        //     path = path.replace('/index.vue', '');
        //     let name;
        //     // 拼接'_'只是方便下划线转驼峰
        //     if (path.indexOf('/') !== -1) {
        //         name = '_' + path.split('/').pop();
        //     } else if (path.indexOf('\\') !== -1) {
        //         name = '_' + path.split('\\').pop();
        //     }
        //     if (name) {
        //         app.component(name.toCamelCase(), component as never);
        //     } else {
        //         console.error(`${path}无法提取组件命名`)
        //     }
        // })
    },
};
